import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '../views/index.vue'
import repairlist from '../views/repairlist.vue'
import login from '../views/login.vue'
import store from '../store'
import luser from '../views/lscUsers.vue'
import ljsxq from '../views/lscjsxq.vue'
import lsettle from '../views/lscSettle.vue'
import wxkd from '../views/wxkd.vue'
import jg from '../views/testjg.vue'
import lscvip from '../views/lscvip.vue'
import lscclgl from '../views/lscclgl.vue'
import lsctzzf from '../views/lsctzzf.vue'

//zb
import staff from '../views/zbStaff.vue'
import job from '../views/zbjob.vue'
import zbdimission from '../views/zbdimission.vue'
import catalogue from '../views/zbcatalogue.vue'

import order from '../views/Orderdetails.vue'
import rework from '../views/rework.vue'
import rescuekd from '../views/rescuekd.vue'
//----xzh
import HomePage from '@/views/HomePage'
import BusinessPage from '@/views/BusinessPage'
import ArtisanGradePage from '@/views/ArtisanGradePage'
import TeamOrGroupPage from '@/views/TeamOrGroupPage'
import LegworkVehicle from '@/views/LegworkVehicle'
import AdditionalRole from '@/views/AdditionalRole'
import addRole from '@/views/addRole'


//----hzhh
import fdjpp from '../views/fdjpp.vue'
import cxda from '../views/cxda.vue'
import ghs from '../views/ghs.vue'
import xmwx from '../views/xmwx.vue'
import shop from '../views/shop.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: login
  },
  {
    path: '/index',
    name: 'index',
    component: index,
    children:[
      //--xzh  首页
      {
        path: '',
        name: 'HomePage',
        component: HomePage,
        children:[
          {
            path: '',
            name: 'BusinessPage',
            component: BusinessPage,
          }
        ]
      },
      // xzh 星级
      {
        path: '/index/ArtisanGradePage',
        name: 'ArtisanGradePage',
        component: ArtisanGradePage,
       },
       {
        path: '/index/cxda',
        name: 'cxda',
        component: cxda,
       },
       //xzh 技工组 
       {
        path: '/index/LegworkVehicle',
        name: 'LegworkVehicle',
        component: LegworkVehicle,
       }, 
       {
        path: '/index/ghs',
        name: 'ghs',
        component: ghs,
       }, 
         //xzh 技工组车辆 
         {
          path: '/index/TeamOrGroupPage',
          name: 'TeamOrGroupPage',
          component: TeamOrGroupPage,
         },
         //附加权限 
         {
          path: '/index/AdditionalRole',
          name: 'AdditionalRole',
          component: AdditionalRole,
         }, 
         {
          path: '/index/fdjpp',
          name: 'fdjpp',
          component: fdjpp,
         }, 
         {
          path: '/index/shop',
          name: 'shop',
          component: shop,
         }, 
           //角色附加
           {
            path: '/index/addRole',
            name: 'addRole',
            component: addRole,
           }, 
           {
            path: '/index/lscvip',
            name: 'lscvip',
            component: lscvip
          },
          {
            path: '/index/lscclgl',
            name: 'lscclgl',
            component: lscclgl
          },
          {
            path: '/index/xmwx',
            name: 'xmwx',
            component: xmwx
          },
      {
        path: '/index/lsctzzf/:rid/:price',
        name: 'lsctzzf',
        component: lsctzzf
      },
      {
        path: '/index/lsettle',
        name: 'lsettle',
        component: lsettle
      },
      {
        path: '/index/ljsxq/:id',
        name: 'ljsxq',
        component: ljsxq
      },
      {
        path: '/index/order/:id/:cz',
        name: 'order',
        component: order
      },
      {
        path: '/index/rework/:id',
        name: 'rework',
        component: rework
      },
      {
        path: '/index/repairlist',
        name: 'repairlist',
        component: repairlist
      },
      {
        path: '/index/luser',
        name: 'luser',
        component: luser
      },
      {
        path: '/index/luser',
        name: 'luser',
        component: luser
      },
      {
        path: '/index/wxkd',
        name: 'wxkd',
        component: wxkd
      },
      {
        path: '/index/jg',
        name: 'jg',
        component: jg
      },
      {
        path: '/index/staff',
        name: 'staff',
        component: staff
      },
      {
        path: '/index/job',
        name: 'job',
        component: job
      },
      {
        path: '/index/dim',
        name: 'zbdimission',
        component: zbdimission  
      },
      {
        path: '/index/cate',
        name: 'catalogue',
        component: catalogue  
      },
      {
        path:'/index/rescuekd',
        name:'rescuekd',
        component:rescuekd
      }
    ]
  },
]

const router = new VueRouter({
  routes
})

router.beforeEach((to,from,next)=>{
  //白名单
  if(to.path=="/"){
    next();
  }else{
    //黑名单
    if(store.getters.getUser==null){
      alert("请登陆");
      next("/");
    }else{
      next();
    }
  }
})

export default router
